import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nyh_motorcade_app/styles/colors.dart';
import 'package:nyh_motorcade_app/widgets/custom_app_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'feedback_controller.dart';

class FeedbackPage extends StatelessWidget {
  final controller = Get.put(FeedbackController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colours.color_background,
      appBar: CustomAppBar(context: context, title: "意见反馈"),
      body: Column(
        children: [
          Container(
            padding: EdgeInsets.only(bottom: 16.w),
            margin: EdgeInsets.all(16.w),
            decoration: BoxDecoration(
              color: Colours.color_white,
              borderRadius: BorderRadius.circular(10.w),
            ),
            child: TextField(
              focusNode: controller.feedbackFocus,
              keyboardType: TextInputType.multiline,
              maxLines: 15,
              minLines: 7,
              maxLength: 200,
              cursorColor: Colours.color_theme,
              style: TextStyle(
                color: Colours.color_text_theme,
                fontSize: 14.sp,
                height: 1.5,
              ),
              decoration: InputDecoration(
                border: OutlineInputBorder(
                  gapPadding: 0,
                  borderRadius: BorderRadius.circular(10.w),
                  borderSide: BorderSide(
                    width: 0,
                    style: BorderStyle.none,
                  ),
                ),
                filled: true,
                fillColor: Colours.color_white,
                isCollapsed: true,
                contentPadding: EdgeInsets.only(left: 16.w, top: 10.w, right: 10.w),
                isDense: true,
                hintText: "请填写5个字以上的问题描述,以便我们更好的帮您解决问题",
                hintStyle: TextStyle(
                  color: Colours.color_b7b7c0,
                  fontSize: 14.sp,
                ),
                counterStyle: TextStyle(
                  fontSize: 12.sp,
                  color: Colours.color_b7b7c0,
                ),
              ),
              onChanged: (value) {
                controller.setFeedback(value);
              },
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 16.w),
            child: GetBuilder<FeedbackController>(
              builder: (controller) {
                return TextButton(
                  onPressed: () {
                    controller.submitFeedback();
                  },
                  child: Text(
                    "提交",
                    style: TextStyle(
                      color: Colours.color_white,
                      fontSize: 16.sp,
                    ),
                  ),
                  style: ButtonStyle(
                    backgroundColor: MaterialStateProperty.all(
                      controller.feedback.isNotEmpty ? Colours.color_theme : Colours.color_ffd599,
                    ),
                    overlayColor: MaterialStateProperty.all(
                      controller.feedback.isNotEmpty ? Colours.color_theme_deep : Colours.color_ffd599,
                    ),
                    shape: MaterialStateProperty.all(
                      RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(28.w),
                      ),
                    ),
                    minimumSize: MaterialStateProperty.all(Size(double.infinity, 48.w)),
                  ),
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}
